package mygame.chameleonpoker;

import java.util.ArrayList;
import java.util.List;

import mygame.chameleonpoker.PokerCards.Card;

public class Player {
	
	private List<Card> cards = new ArrayList<Card>();
	private List<Card> buried_cards = new ArrayList<Card>();
	private List<Boolean> cards_selected = new ArrayList<Boolean>();
	private int num_of_cards;
	private int num_of_buried_cards;
	private Card leaded_card;
	private boolean wait_for_lead;
	private boolean lead;
	private boolean bury;
	
	public Player() {
		num_of_cards = 0;
		num_of_buried_cards = 0;
		leaded_card = new Card();
		wait_for_lead = true;
		lead = false;
		bury = false;
	}
	
	public void get_card(Card card) {
		cards.add(card);
		cards_selected.add(false);
		num_of_cards++;
		Assets.dealCard.play(1);
	}
	
	public void lead_card(int location) {
		leaded_card = cards.remove(location);
		cards_selected.remove(location);
		num_of_cards--;
		lead = true;
		bury = false;
		Assets.leadCard.play(1);
	}
	
	public void bury_card(int location) {
		buried_cards.add(cards.remove(location));
		cards_selected.remove(location);
		num_of_cards--;
		num_of_buried_cards++;
		bury = true;
		lead = false;
		Assets.buryCard.play(1);
	}
	
	public int get_numb_of_cards() {
		return num_of_cards;
	}
	
	public int get_numb_of_buried_cards() {
		return num_of_buried_cards;
	}
	
	public List<Card> get_cards() {
		return cards;
	}
	
	public List<Boolean> get_cards_state() {
		return cards_selected;
	}
	
	public int have_cards_selected() {
		for(int i = 0; i < num_of_cards; i++) {
			if(cards_selected.get(i))
				return i;
			else
				continue;
		}
		return -1;	
	}
	
	public List<Card> get_buried_card() {
		return buried_cards;
	}
	
	public Card get_leaded_card() {
		return leaded_card;
	}
	
	public boolean get_wait_status() {
		return wait_for_lead;
	}	
	
	public void set_wait_status(boolean state) {
		wait_for_lead = state;
	}
	
	public boolean is_card_leaded() {
		return lead;
	}
	
	public boolean is_card_buried() {
		return bury;
	}
	
	public void clear_state() {
		bury = false;
		lead = false;
	}
	
	public void reset() {
		cards.clear();
		buried_cards.clear();
		cards_selected.clear();
		num_of_cards = 0;
		num_of_buried_cards = 0;
		leaded_card.set_to_null();
		wait_for_lead = true;
		lead = false;
		bury = false;
	}
}
